<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">
    $("#itemListTable").treeTable({expandLevel : 2});
</script>
<div class="panel-body p0 mt5">
    <div class="btn-group col-lg-3">
        <button type="button" class="btn btn-success col-lg-6" onclick="addPrescItem('0')">添加药品</button>
        <button type="button" class="btn btn-info col-lg-6" onclick="subPresc('0')">子处方</button>
    </div>
    <div>
        <table  class="table table-bordered mg-t datatable" id="itemListTable">
            <thead>
            <tr>

                <th>药品名称</th>
                <th style="display:none"></th>
                <th>厂家</th>
                <th>单次用量</th>
                <th>用量单位</th>

                <th>用药天数</th>
                <th>途径</th>
                <th>频次</th>
                <th>包装规格</th>
                <th>药品数量</th>
                <th>包装单位</th>
                <th>单价</th>
                <th>总价</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
                <c:forEach items="${itemList}" var="item">
                    <c:choose>
                        <c:when test="${!empty item.parent.id}">
                            <tr id='${item.id}' pId='${item.parent.id}'>
                        </c:when>
                        <c:otherwise>
                            <tr id='${item.id}'>
                        </c:otherwise>
                    </c:choose>
                        <td>${item.drugName}</td>
                    <td style="display:none"><input type="hidden" value="${item.id}"/></td>
                        <td>${item.firmName}</td>
                        <td>${item.singleDosage}</td>
                        <td>${fns:getDictLabels(item.singleUnit, 'dose_unit', '')}</td>

                        <td>${item.abidance}</td>
                        <td><input type="hidden" value="${item.channel}"> ${fns:getSysDictLabel(item.channel, 'ADMINISTRATION_DICT', '')}</td>
                        <td><input type="hidden" value="${item.frequency}">${fns:findFreqDesc(item.frequency, '')}</td>
                        <td>${item.packageSpec}</td>
                    <td>${item.num}</td>
                        <td>${fns:getDictLabels(item.packageUnit, 'SPEC_UNIT', '')}</td>
                        <td><input type="hidden" value="${item.priceId}"/><fmt:formatNumber value="${item.price}" pattern="#.####" minFractionDigits="2" /></td>
                        <td><fmt:formatNumber value="${item.sumPrice}" pattern="#.####" minFractionDigits="2" /></td>
                        <td><c:choose>
                            <c:when test="${(apply.chargeFlag==0 || apply.chargeFlag=='0') && (apply.confirmFlag==0 || apply.confirmFlag=='0') &&  apply.prescStatus == '0'}">
                                <a href="#"  class="btn btn-danger btn-xs" onclick="confirmExtend('确认要删除该药品处方吗？',function(){deleteLoad('applyDiv','prescWesternItemDiv','${ctx}/doctor/prescriptionItem/delete?id=${item.id}','${ctx}/doctor/prescriptionApply/applyIndex?clinicId=${apply.clinicId}&patientId=${apply.patientId}&visitId=${apply.visitId}','${ctx}/doctor/prescriptionItem/index?applyId=${item.applyId}&inoroutFlag=0')})">删除</a>
                            </c:when>
                            <c:otherwise>
                               <%-- <a href="#"  class="btn btn-default btn-xs">删除</a>--%>
                            </c:otherwise>
                        </c:choose>
                        </td>
                        </tr>

                </c:forEach>
            </tbody>
        </table>
    </div>
</div>



